<%@page import="com.ContasCorrente"%>
<%@ page import="com.FluxoCaixa"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="main" />
<g:set var="entityName"
	value="${message(code: 'fluxoCaixa.label', default: 'FluxoCaixa')}" />
<title><g:message code="default.create.label"
		args="[entityName]" />
</title>

<script type="text/javascript">

	function mostraContasReceberPagar(){
		jQuery('#dinamicTbody tr:not(#default)').remove()
		
		var dataFim = jQuery('#dataFinal').val();
		var dataInicio = jQuery('#dataInicial').val();
		console.log(dataFim +" - "+dataInicio)
		
		jQuery.ajax({
			type : "POST",
			url : "/cash/fluxoCaixa/getContas",
			data : {
				'dataFim' : dataFim,
				'dataInicio' : dataInicio
			},
			success : function(result) {
				//jQuery('#tipoAcao').append(options)
				console.log("result: "+result)
			},
			error : function(error) {
				alert("erro ao buscar Contas." + error)
			}
		});

	}

</script>


</head>
<body>
	<div class="nav">
		<span class="menuButton"><a class="home"
			href="${createLink(uri: '/')}"><g:message
					code="default.home.label" /> </a> </span> <span class="menuButton"><g:link
				class="list" action="list">
				<g:message code="default.list.label" args="[entityName]" />
			</g:link> </span>
	</div>
	<h1 id="pageName">Cria Fluxo Caixa</h1>

	<g:if test="${flash.message}">
		<div class="message">
			${flash.message}
		</div>
	</g:if>
	<g:hasErrors bean="${fluxoCaixaInstance}">
		<div class="errors">
			<g:renderErrors bean="${fluxoCaixaInstance}" as="list" />
		</div>
	</g:hasErrors>
	<g:form action="save">
		<table class="IadTableForm">
			<tbody>
			
				<tr class="prop">
					<td valign="top" class="name">
						<label for="contasCorrentes">
							<g:message code="fluxoCaixa.contasCorrentes.label" default="Contas Correntes:" />
						</label>
					</td>
					
					<td valign="top" class="value" >
						<g:select name="contasCorrentes.id" from="${com.ContasCorrente.list()}" multiple="true"
							optionKey="id"/>
					</td>
				
					<td valign="top" class="name"><label for="dataInicial"><g:message
								code="fluxoCaixa.dataInicial.label" default="Data Inicial:" />
					</label></td>
					<td valign="top"
						class="value ${hasErrors(bean: fluxoCaixaInstance, field: 'dataInicial', 'errors')}">
						<g:datePicker name="dataInicial" precision="day"
							value="${fluxoCaixaInstance?.dataInicial}" /></td>
			
					<td valign="top" class="name"><label for="dataFinal"><g:message
								code="fluxoCaixa.dataFinal.label" default="Data Final:" />
					</label></td>
					<td valign="top"
						class="value ${hasErrors(bean: fluxoCaixaInstance, field: 'dataFinal', 'errors')}">
						<g:datePicker name="dataFinal" precision="day"
							value="${fluxoCaixaInstance?.dataFinal}" /></td>
				</tr>

				<!-- tr class="prop">
					<td valign="top" class="name"><label for="contasPagar"><g:message
								code="fluxoCaixa.contasPagar.label" default="Contas Pagar" />
					</label></td>
					<td valign="top"
						class="value ${hasErrors(bean: fluxoCaixaInstance, field: 'contasPagar', 'errors')}">
						<g:select name="contasPagar" from="${com.ContasPagar.list()}"
							multiple="yes" optionKey="id" size="5"
							value="${fluxoCaixaInstance?.contasPagar*.id}" /></td>
				</tr>

				<tr class="prop">
					<td valign="top" class="name"><label for="contasReceber"><g:message
								code="fluxoCaixa.contasReceber.label" default="Contas Receber" />
					</label></td>
					<td valign="top"
						class="value ${hasErrors(bean: fluxoCaixaInstance, field: 'contasReceber', 'errors')}">
						<g:select name="contasReceber" from="${com.ContasReceber.list()}"
							multiple="yes" optionKey="id" size="5"
							value="${fluxoCaixaInstance?.contasReceber*.id}" /></td>
				</tr-->

			</tbody>
		</table>

		<div class="buttons">
			<span class="button"><g:submitButton name="create"
					class="save"
					value="${message(code: 'default.button.create.label', default: 'Create')}" />
			</span>
		</div>
	</g:form>
</body>
</html>
